#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls --color=auto'
alias mvn="mvn --settings='${HOME}/.local/lib/conf/settings.xml'"

# stack
if [ -e "$HOME/.local/bin/stack" ]
then
  eval "$(stack --bash-completion-script stack)"
fi

# scala
if [ -e "/usr/bin/scala" ]
then
  alias scala='scala -Xjline:off'
  alias sbt='sbt -ivy "$XDG_DATA_HOME"/sbt/ivy2 -sbt-dir "$XDG_DATA_HOME"/sbt'
fi

# PS1='[\u@\h \W]\$ '

### SELF PS [prompt sign]
exitstatus() {
    if [[ $? == 0 ]]
    then
        printf '\033[1;32m yes \033[0m'
    else
        printf '\033[1;31m no \033[0m'
    fi
}
export PS0='\[\033[0;36m\]Out[\#]:= \[\033[0m\]\n'
export PS1='[\u@\h \w \A] \[\033[1;36m\][\$]\[\033[0m\] [$(exitstatus)]\n\[\033[0;33m\]In[\#]:= \[\033[0m\]'
export PS2=' ~> '

# yarn
alias yarn='yarn --use-yarnrc "$XDG_CONFIG_HOME/yarn/config"'

eval "$(dircolors "$XDG_CONFIG_HOME"/dircolors)"

eval "$(pandoc --bash-completion)"

# hitokoto (bad netwroks)
# ${HOME}/.local/bin/self-script/hitokoto

# yt-dlp
function yd() {
    local url="$1"
    if [ -z "$url" ]
    then
        echo "please give a url"
	return 1
    fi
    yt-dlp -o "%(channel)s/%(playlist_title)s/%(title)s.%(ext)s" \
        -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' \
        "$url"
}

export GPG_TTY="$(tty)"

# pyenv
# export PYENV_ROOT="$HOME/workspace/others/pyenv"
# export PATH="$PYENV_ROOT/bin":"$PATH"
# eval "$(pyenv init -)"
# eval "$(pyenv virtualenv-init -)"
